#include "mover.h"
#include <graphics.h>
#include <windows.h>
#include "graph.h"

mover::mover() :
	poisition({0.0f, 0.0f}),
	velocity({0.0f,0.0f}),
	acceleration({0.0f,0.0f}),
	mass(5.0f)
{

}

mover::mover(const vector2& _position, float _mass):
	poisition(_position),
	velocity({ 0.0f,0.0f }),
	acceleration({ 0.0f,0.0f }),
	mass(_mass)
{
}

mover::~mover()
{
}

void mover::Drag(const Liquid& liquid)
{
	vector2 vel = velocity;
	this->AddForce(liquid.f * vel.GetMag() * vel.GetMag() * vel.Normalize() * -1.0f);
}

void mover::AddForce(vector2 force)
{
	acceleration.Add(force / (mass));
}

void mover::Show()
{
	setfillcolor(YELLOW);
	solidcircle(X((int)poisition.x), Y((int)poisition.y), mass);
}

void mover::Update()
{
	velocity.Add(acceleration);
	poisition.Add(velocity);
	acceleration.Mul(0.0f);
}

const vector2& mover::GetPos()
{
	return poisition;
}

const vector2& mover::GetVelocity()
{
	return velocity;
}

float mover::GetMass()
{
	return mass;
}

void mover::SetPos(vector2 pos)
{
	this->poisition = pos;
}

void mover::SetMass(float mass)
{
	this->mass = mass;
}

void mover::SetVelocity(vector2 velocity)
{
	this->velocity = velocity;
}
